import Vue from "vue";
import App from "./App.vue";
import router from "./router";
Vue.config.productionTip = false;
// 引入全局基础css
import "./assets/base.css";
// 引入baseURL
import baseurl from './config.json'
// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// 富文本编辑器相关的样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)
// 配置axios
import Axios from "axios";
Vue.prototype.$http = Axios;
Axios.defaults.baseURL = baseurl.baseURL;


// 导入树形表格组件
import TreeTable from 'vue-table-with-tree-grid'
// 注册全局组件
Vue.component('tree-table', TreeTable)

// 导入nprogress
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'

// 请求拦截器
Axios.interceptors.request.use(function (config) {
  // Do something before request is sent
  // config.headers
  // console.log(config.headers)
  // 当我们去获取需要权限的数据的时候 一定要把令牌传到服务器
  // 
  config.headers.Authorization = window.sessionStorage.getItem("token");
  Nprogress.start()
  return config;
}, function (error) {
  // Do something with request error
  return Promise.reject(error);
});
// 隐藏进度条
Axios.interceptors.response.use((config) => {
  Nprogress.done()
  return config
})

// 时间过滤器
Vue.filter("dataFormat", function (originval) {
  const date = new Date();
  const year = date.getFullYear();
  const mouth = (date.getMonth() + 1 + "").padStart(2, "0");
  const day = (date.getDate() + "").padStart(2, "0");
  const hours = (date.getHours() + "").padStart(2, "0");
  const mintus = (date.getMinutes() + "").padStart(2, "0");
  const seconds = (date.getSeconds() + "").padStart(2, "0")
  return `${year}-${mouth}-${day} ${hours}:${mintus}:${seconds}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount("#app");








// const result = await this.$confirm(
//   "此操作将永久删除该文件, 是否继续?",
//   "提示",
//   {
//     confirmButtonText: "确定",
//     cancelButtonText: "取消",
//     type: "warning"
//   }
// ).catch(error => {
//   return "clac";
// });
// console.log(result);
// if (result === "clac") {
//   return this.$message({
//     type: "info",
//     message: "已取消删除"
//   });
// }
// if (result === "confirm") {
//   const { data: res } = await this.$http.delete(
//     `categories/${this.cateId}/attributes/${id}`
//   );
//   console.log(res);
//   if (res.meta.status !== 200) {
//     return this.$message.error("删除参数失败");
//   }
//   this.$message.success("删除参数成功");
//   this.getTableDate();
// }